﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace FoodManager
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();           
        }
        OrderClass CurrentOrder = new OrderClass();
        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'db.tblkhachhang' table. You can move, or remove it, as needed.
            this.tblkhachhangTableAdapter.Fill(this.db.tblkhachhang);
            
            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (CurrentOrder == null) CurrentOrder = new OrderClass();
            CurrentOrder.DiaChi = txtDiaChiGiaoHang.Text;
            CurrentOrder.Id = 0;
            CurrentOrder.IdKhachHang = Convert.ToInt32(cbKhachHang.SelectedValue);
            CurrentOrder.IdUser = Functions.GetIdCurrentUser();
            CurrentOrder.MaDonHang = txtMaDonHang.Text;
            CurrentOrder.NgayGiao = dtNgayGiao.Value;
            CurrentOrder.NgayLap = DateTime.Now;
            CurrentOrder.NhanVienGiaoHang = txtNhanVienGiaoHang.Text;
            CurrentOrder.NhanVienQuanLy = txtNhanVienPhuTrach.Text;
            CurrentOrder.TrangThai = cbTrangThai.Text == "Đã thanh toán" ? Convert.ToByte(1) : Convert.ToByte(2);
            frNhapSanPhamChoDonHang f = new frNhapSanPhamChoDonHang(this.CurrentOrder);
            f.ShowDialog(this);
            
        }
    }
}
